Skip to content

Add MeshModel summary filter API integration and unit tests#918

Open
Amr-Shams wants to merge 6 commits intomeshery:masterfrom
Amr-Shams:feat/meshmodel-summary-filters-registry-api
Open

Add MeshModel summary filter API integration and unit tests#918
Amr-Shams wants to merge 6 commits intomeshery:masterfrom
Amr-Shams:feat/meshmodel-summary-filters-registry-api

Conversation

@Amr-Shams
Copy link
Contributor

Description
This PR integrates the new MeshModel summary filters into the registry API and adds unit tests for summary aggregation behavior.
This PR fixes #917

Notes for Reviewers

  • added unit test for both filters

Signed commits

  • Yes, I signed my commits.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the MeshModel registry API by introducing new capabilities for retrieving aggregated summary data for components and relationships. It provides a standardized approach to query and summarize registry entities, offering insights into their distribution across various dimensions. This improvement aims to facilitate better data analysis and management within the MeshModel ecosystem.

Highlights

  • New Summary Filter Interfaces: Introduced generic Summary and SummaryFilter interfaces to standardize the retrieval of aggregated summary data across different MeshModel entities.
  • Component Summary API: Implemented a new ComponentSummaryFilter and ComponentSummary structure, along with a GetComponentSummary method in RegistryManager, enabling aggregated queries for MeshModel components based on various dimensions like model, category, and registrant.
  • Relationship Summary API: Implemented a new RelationshipSummaryFilter and RelationshipSummary structure, along with a GetRelationshipSummary method in RegistryManager, enabling aggregated queries for MeshModel relationships based on dimensions like model, kind, type, and sub-type.
  • Error Handling Refactoring: Refactored the ErrGetById error creation into a dedicated registry/errors package, centralizing error definitions and improving maintainability.
  • Comprehensive Unit Tests: Added extensive unit tests for both the new component and relationship summary filters, ensuring the correctness and reliability of the aggregation logic.
Changelog
  • models/meshmodel/entity/types.go
    • Added Summary interface for entities providing key-value and count data.
    • Added generic SummaryFilter interface for entities exposing aggregated summary data.
  • models/meshmodel/registry/error.go
    • Imported registryerrors package.
    • Refactored ErrGetById to delegate error creation to the new registryerrors package.
  • models/meshmodel/registry/errors/error.go
    • Added new file error.go to define common registry errors.
    • Implemented ErrGetById function for consistent error handling across the registry.
  • models/meshmodel/registry/registry.go
    • Imported regv1alpha3 and regv1beta1 packages for summary filters.
    • Added GetComponentSummary method to RegistryManager to retrieve component summary data.
    • Added GetRelationshipSummary method to RegistryManager to retrieve relationship summary data.
  • models/meshmodel/registry/v1alpha3/relationship_filter.go
    • Updated GetById to use the new registryerrors.ErrGetById function.
  • models/meshmodel/registry/v1alpha3/relationship_summary.go
    • Added new file relationship_summary.go to define RelationshipSummaryFilter and related types.
    • Implemented Validate method for RelationshipSummaryFilter to check include dimensions.
    • Implemented GetSummary method for RelationshipSummaryFilter to aggregate relationship data based on specified criteria.
  • models/meshmodel/registry/v1alpha3/relationship_summary_test.go
    • Added new file relationship_summary_test.go containing unit tests for RelationshipSummaryFilter.
  • models/meshmodel/registry/v1beta1/category_filter.go
    • Updated GetById to use the new registryerrors.ErrGetById function.
  • models/meshmodel/registry/v1beta1/component_filter.go
    • Updated GetById to use the new registryerrors.ErrGetById function.
    • Adjusted formatting for status filtering in the Get method.
  • models/meshmodel/registry/v1beta1/component_summary.go
    • Added new file component_summary.go to define ComponentSummaryFilter and related types.
    • Implemented Validate method for ComponentSummaryFilter to check include dimensions.
    • Implemented GetSummary method for ComponentSummaryFilter to aggregate component data based on specified criteria.
  • models/meshmodel/registry/v1beta1/component_summary_test.go
    • Added new file component_summary_test.go containing unit tests for ComponentSummaryFilter.
  • models/meshmodel/registry/v1beta1/model_filter.go
    • Updated GetById to use the new registryerrors.ErrGetById function.
  • models/meshmodel/registry/v1beta1/policy_filter.go
    • Updated GetById to use the new registryerrors.ErrGetById function.
Activity
  • Unit tests were added for both the new component and relationship summary filters.
  • All commits have been signed off by the author.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively integrates new MeshModel summary filters into the registry API and includes comprehensive unit tests, which is great. The refactoring of error handling into a dedicated package is a good move for code organization. I've provided a couple of suggestions to refactor the new GetSummary methods to reduce code duplication, which will enhance long-term maintainability.

@lekaf974
Copy link
Contributor

lekaf974 commented Mar 2, 2026

Were now using schemas driven development and IMo such struct should be implemented in meshery/schemas

return nil
}

func (relationshipFilter *RelationshipSummaryFilter) GetSummary(db *database.Handler) (*RelationshipSummary, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where this method will be used ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a cross repo issue, here you can check the (meshery/meshery#17457)

@Amr-Shams
Copy link
Contributor Author

Were now using schemas driven development and IMo such struct should be implemented in meshery/schemas

u mean the new filter ?

@lekaf974
Copy link
Contributor

lekaf974 commented Mar 2, 2026

Were now using schemas driven development and IMo such struct should be implemented in meshery/schemas

u mean the new filter ?

I think all structs created should go there to have a unique source of truth but perhaps it needs to be validated.

cc: @leecalcote, @aabidsofi19 any thoughts ?

@aabidsofi19
Copy link
Member

@lekaf974 absolutely right . All structs models, requests payload, filters , response should be defined and generated using openapi schemas

"github.com/stretchr/testify/require"
)

type relationshipSummaryRecord struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentionned in other comment this struct should be added in meshery/schemas repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair point, but this one is test-only, not an API struct.

relationshipSummaryRecord is just a small DB seed helper for unit tests.
After switching to generated schema types, using RelationshipDefinition directly in test migrate/seed was failing because of nested ModelReference parsing in GORM.

So this isn’t a new runtime model, and nothing API-related is being defined here.
The actual filter/response shapes are in meshery/schemas.

@Amr-Shams
Copy link
Contributor Author

@lekaf974 i have open a pr, and once the schemes is approved i will push the local changes here

@Amr-Shams Amr-Shams requested a review from lekaf974 March 3, 2026 16:06
@Amr-Shams Amr-Shams force-pushed the feat/meshmodel-summary-filters-registry-api branch from a9591a4 to 4b2d740 Compare March 3, 2026 16:14
Signed-off-by: Amr-Shams <amr.shams2015.as@gmail.com>
Signed-off-by: Amr-Shams <amr.shams2015.as@gmail.com>
…ount

Signed-off-by: Amr-Shams <amr.shams2015.as@gmail.com>
Signed-off-by: Amr-Shams <amr.shams2015.as@gmail.com>
Signed-off-by: Amr-Shams <amr.shams2015.as@gmail.com>
Signed-off-by: Amr-Shams <amr.shams2015.as@gmail.com>
@Amr-Shams Amr-Shams force-pushed the feat/meshmodel-summary-filters-registry-api branch from 4b2d740 to ab92b53 Compare March 3, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add typed MeshModel summary API integration and tests

3 participants